package com.chuang.server.service.impl;

import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.chuang.server.mapper.BillMapper;
import com.chuang.server.pojo.Bill;

import com.chuang.server.pojo.ResultBean;
import com.chuang.server.pojo.ResultPageBean;
import com.chuang.server.pojo.User;
import com.chuang.server.service.BillService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 账单表 服务实现类
 * </p>
 *
 * @author vicente
 * @since 2022-01-15
 */
@Service
public class BillServiceImpl extends ServiceImpl<BillMapper, Bill> implements BillService {
    @Autowired
    private BillMapper billMapper;
    @Override
    public ResultBean billList() {
        return ResultBean.success("成功",billMapper.billList());
    }

    @Override
    public ResultPageBean pageList(JSONObject jsonObject) {
        Integer page = jsonObject.getInteger("page");
        Integer pageSize = jsonObject.getInteger("pageSize");
        Page<Bill> billPage = new Page<>(page, pageSize);
        IPage<Bill> billIPage = billMapper.selectPageVo(billPage, 0);
        return ResultPageBean.success("成功",billIPage.getRecords(),billIPage.getTotal(),billIPage.getSize(),billIPage.getCurrent(),billIPage.getPages());
    }
}
